I have created a maven spring boot project with React, when i run the webpack the Link to works perfectly, when i try to run with mvn spring-boot run, it throws an error 404 and page not found,
My client.js,
import React from 'react';
import { render } from 'react-dom';
import { Route,Router, browserHistory} from 'react-router';
import Home from './components/Home';
import About from './components/About';
render((
<Router history={browserHistory}>
<Route path="/Home" component={Home}></Route>
<Route path="/about" component={About}></Route>
</Router>
), document.getElementById('reactDiv'));
Home component,
import React from 'react';
export default class Home extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h2> Home Page </h2>
<Link to={`/about`} target="_blank">
About
</Link>
</div>
);
}
}
About component,
import React from 'react';
export default class About extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h2> About Page </h2>
</div>
);
}
}
Copyright Notice:Content Author:「Nithila」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39092749/react-route-link-to-is-not-working-in-maven-springboot-project